class AddIndexes < ActiveRecord::Migration
  def self.up
    #Announcement
    add_index :announcements, :member_id
    add_index :announcements, :admin
    #AttendanceRecord
    add_index :attendance_records, [:event_id, :member_id], :unique => true
    add_index :attendance_records, [:waitlist, :event_id]
    add_index :attendance_records, [:driver, :waitlist]
    add_index :attendance_records, :deleted
    #Event
    add_index :events, [:deleted, :event_type]
    add_index :events, :semester_index
    add_index :events, :date
    #Member
    add_index :members, [:first_name, :last_name]
    add_index :members, :last_name
    add_index :members, :username, :unique => true
    add_index :members, :birthday
    add_index :members, [:deleted, :status]
    add_index :members, :admin
    #PledgeClass
    add_index :pledge_classes, :name, :unique => true
    add_index :pledge_classes, :semester_index, :unique => true
    #Position
    add_index :positions, :member_id
    add_index :positions, :semester_index
    #Toggles
    add_index :toggles, :name, :unique => true
    change_column :toggles, :name, :string, {:limit => 20, :null => false}
  end

  def self.down
    #Announcement
    remove_index :announcements, :member_id
    remove_index :announcements, :admin
    #AttendanceRecord
    remove_index :attendance_records, [:event_id, :member_id]
    remove_index :attendance_records, [:waitlist, :event_id]
    remove_index :attendance_records, [:driver, :waitlist]
    remove_index :attendance_records, :deleted
    #Event
    remove_index :events, [:deleted, :event_type]
    remove_index :events, :semester_index
    remove_index :events, :date
    #Member
    remove_index :members, [:first_name, :last_name]
    remove_index :members, :last_name
    remove_index :members, :username
    remove_index :members, :birthday
    remove_index :members, [:deleted, :status]
    remove_index :members, :admin
    #PledgeClass
    remove_index :pledge_classes, :name
    remove_index :pledge_classes, :semester_index
    #Position
    remove_index :positions, :member_id
    remove_index :positions, :semester_index
    #Toggles
    remove_index :toggles, :name
    change_column :toggles, :name, :string
  end
end
